package com.example.licenseappserver;

public class Client {


    private String username;
    private String CDK;
    private String licenseType;
    private String serial;
    private int num;
    public int currentNum;

    public Client(String username, String CDK, String licenseType, String serial) {
        this.username = username;
        this.CDK = CDK;
        this.licenseType = licenseType;
        this.serial = serial;
        if(licenseType.equals("One")) num=1;
        if(licenseType.equals("Two")) num=2;
        currentNum=0;
    }

    public String getUsername() {
        return username;
    }

    public String getCDK() {
        return CDK;
    }

    public String getLicenseType() {
        return licenseType;
    }

    public String getSerial() {
        return serial;
    }

    public int getNum() {
        return num;
    }

    @Override
    public String toString() {
        return username+","+CDK+","+licenseType+","+serial;
    }

    public static Client fromString(String str){
        String [] ini= str.split(",");
        if(ini.length==4){
            return new Client(ini[0],ini[1],ini[2],ini[3]);
        }
        else return null;
    }

}
